package text;

/**
 * Created with IntelliJ IDEA.
 * Description:
 */
//class Text{
//    public Object[] objects =new Object[10];
//    public  void setNum(int pos ,Object object){
//        objects[pos] =object;
//    }
//    public Object getArray(int pos){
//        return objects[pos];
//    }
//}
class Text <T> {
    public Object[] objects =new Object[10];
    public  void setNum(int pos ,T object){
        objects[pos] =object;
    }
    public T getArray(int pos){
        return (T)objects[pos];
    }
}
public class Text1 {
    public static void main(String[] args) {
        //Text<Integer> text =new Text<Integer>(); 可以省略后面的，Java在底层会自动实现
        Text<Integer> text =new Text<>();
        text.setNum(0,10);
        System.out.println(text.getArray(0));
    }
    public static void main2(String[] args) {
        Text text =new Text();
        text.setNum(0,10);
        Integer ret1 =(Integer)text.getArray(0);
        text.setNum(1,"hehe");
        String ret2 =(String) text.getArray(1);
        System.out.println(ret1);
        System.out.println(ret2);
    }
    public static void main1(String[] args) {
        int a =10;
        Integer i1 =  a  ;    //自动装箱,底层代码会实现显示装箱的代码
        Integer i2 =Integer.valueOf(a);  //显示装箱
        int b =i1;            //自动拆箱,底层代码会实现显示拆箱的代码
        int c =i1.intValue();   //显示拆箱
    }
}
